

public abstract aspect IndentedLogging {

	protected int _indentationLevel = 0;
	protected abstract pointcut loggedOperations();

	public IndentedLogging() {
		
	}
	
	before() : loggedOperations() {
		
		System.out.println("Increase Indent");
		_indentationLevel++;
	}

	after() : loggedOperations() {
		
		System.out.println("Decrease Indent");
		_indentationLevel--;
	}

	before() : call(* java.io.PrintStream.println(..)) 
	        && within(IndentedLogging+) {
		for (int i = 0, spaces = _indentationLevel * 4; i < spaces; ++i) {
			System.out.print(" ");
		}
	}
}
